<template>
	<!--发票详情-->
	<view class="content">
		
		<view class="ad-billing">
			<!--表单开始-->
			<form @submit="formSubmit" @reset="formReset" v-model="Rise">
				
				<view class="uni-details-list">
					<view class="title">名称:</view>
					<view class="uni-input-01">
						<view>{{riseListPro.invoiceName}} </view>
					</view>
				</view>
				
				<view class="uni-details-list">
					<view class="title">税号:</view>
					<view class="uni-input-01">
						<view>{{riseListPro.taxNo}} </view>
					</view>
				</view>
				
				<view class="uni-details-list">
					<view class="title">企业地址:</view>
					<view class="uni-input-02">
						<view>{{riseListPro.address}} </view>
					</view>
				</view>
				
				<view class="uni-details-list">
					<view class="title">企业电话:</view>
					<view class="uni-input-02">
						<view>{{riseListPro.phone}} </view>
					</view>
				</view>
				
				<view class="uni-details-list">
					<view class="title">开户银行:</view>
					<view class="uni-input-02">
						<view>{{riseListPro.bankNm}} </view>
					</view>
				</view>
				
				<view class="uni-details-list">
					<view class="title">开户账号:</view>
					<view class="uni-input-02">
						<view>{{riseListPro.bankAccNo}} </view>
					</view>
				</view>
				
				<view class="uni-details-list">
					<view class="title">金额:</view>
					<view class="uni-input-01">
						<input name="input" placeholder="请输入金额" v-model="riseListPro.txnAmt"
							:disabled="flag" />
					</view>
				</view>
				
				<view class="uni-details-list">
					<view class="title">内容:</view>
					<view class="uni-input-02">
						<view>{{riseListPro.content}} </view>
					</view>
				</view>
				<view class="uni-details-list">
					<view class="title">备注:</view>
					<view class="uni-input-02">
						<view>{{riseListPro.memo}} </view>
					</view>
				</view>
				
				<view class="uni-details-list">
					<view class="title">邮箱:</view>
					<view class="uni-input-02">
						<view>{{riseListPro.email}} </view>
					</view>
				</view>
				

				<view>
					<button @click="updateState()" :disabled="flag" class="button">确认开票</button>
					<button @click="turnState()" :disabled="flag" class="button">退回发票</button>
				</view>



			</form>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				riseListPro: {
					id: '',
					invoiceName: '',
					address: '',
					phone: '',
					bankNm: '',
					bankAccNo: '',
					txnAmt: '',
					state: '',
					content:'',
					memo:'',
				},
				flag: true


			}
		},
		onLoad(options) {
			console.log(options.id);
			this.detail(options.id);
		},
		methods: {

			//订单详情 
			detail(id) {
				var me = this;
				console.log(id);
				uni.request({
					url: me.$ServerUrl + '/invoice/api/invoice/getInvoiceById', //通过ID获取发票详情
					data: {
						id: id
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded' // 默认值JSON格式
					},
					method: "GET",
					success(res) {
						console.log(res.data);
						me.riseListPro = res.data;
						console.log("state:" + JSON.stringify(me.riseListPro.state));
						if (res.data.state == '1') {
							me.flag = false
						} else {
							me.flag = true
						}
						console.log(me.flag)

					}
				})
			},
			//修改状态
			updateState() {
				var me = this;
				uni.request({
					url: me.$ServerUrl + '/invoice/api/invoice/submitInvoice', //商户提交发票
					data: {
						id: me.riseListPro.id,
						state: 2,
					},
					header: {
						'content-type': 'application/JSON' // 默认值JSON格式
					},
					method: "POST",
					success(invoice) {
						console.log(invoice)
						uni.showToast({
							title: '开票成功',
							duration: 2000,
							success() {
								uni.redirectTo({
									url: "index"
								})
							}
						});

					}
				})
			},
			//返回发票
			turnState() {
				var me = this;
				uni.request({
					url: me.$ServerUrl + '/invoice/api/invoice/submitInvoice', //商户提交发票
					data: {
						id: me.riseListPro.id,
						state: 4,
					},
					header: {
						'content-type': 'application/JSON' // 默认值JSON格式
					},
					method: "POST",
					success(invoice) {
						console.log(invoice)
						uni.showToast({
							title: '返回成功',
							duration: 2000,
							success() {
								uni.redirectTo({
									url: "index"
								})
							}
						});

					}
				})
			}



		}
	}
</script>

<style>
	page {
		width: 100%;
		height: 100%;
		background-color: #e1e5eb;
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.ad-billing {
		width: 100%;
		height: 100%;
		padding: 10px;
	}

	.uni-details-list {
		border: 1px solid #ffffff;
		display: flex;
		background-color: #ffffff;
		align-items: center;
		padding: 10px;
		margin-bottom: 5px;
		border-radius: 10px;
		margin-left: 10px;
		margin-right: 10px;
	}

	.title {
		font-size: 14px;
		width: 65px;
	}

	.uni-input-01 {
		font-size: 14px;
		margin-left: 10px;
		width: 75%;
		overflow: auto;
	}

	.uni-input-02 {
		font-size: 14px;
		margin-left: 10px;
		width: 75%;
		overflow: auto;
	}
	.uni-input-02 .uni-details-text{
		word-break: normal;
	}

	.button {
		border-radius: 10px;
		margin: 10px;
		color: #FFFFFF;
		background-color: #004FA3;
	}
	
</style>
